var express = require('express.io');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var gen = require('./public/javascripts/config');

gen.log("holla");

var app = express().http().io();

app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.cookieParser());
app.use(express.session({
    secret: 'monkey'
}));
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' === app.get('env')) {
    app.use(express.errorHandler());
}

var parseCookie = require('connect').utils.parseCookie;

app.get('/', function(req, res) {
    res.sendfile(__dirname + '/index.html');
});

app.post('/search', function(req, res){
    console.log('search segment hit');
    res.send('search segment hit');
});

app.io.route('ready', function(req) {
    console.log(req.data);
    req.io.emit('ready-ack',{data:"hahah"});
});

app.io.route('diceRolled', function(req) {});

app.io.route('incomingChatMessage', function(req) {});

app.io.route('connect', function(req) {});

app.listen(3000);
console.log("Server Listening to Port 3000");